package com.yz.newspaper.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yz.newspaper.mapper.ManuscriptIssueMapper;
import com.yz.newspaper.pojo.po.ManuscriptIssue;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yz.newspaper.pojo.unitPo.PageBean;
import com.yz.newspaper.service.IManuscriptIssueService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 稿件发布记录表 服务实现类
 * </p>
 *
 * @author maike
 * @since 2024-04-23
 */
@Service
public class ManuscriptIssueServiceImpl extends ServiceImpl<ManuscriptIssueMapper, ManuscriptIssue> implements IManuscriptIssueService {


    @Override
    public int addManuscript(ManuscriptIssue manuscriptIssue) {

        return baseMapper.insert(manuscriptIssue);
    }

    @Override
    public PageBean<ManuscriptIssue> getAll(String username, String phone, Integer year, Integer month, Integer pageSize, Integer pageNum) {
        PageHelper pageHelper = new PageHelper();
        pageHelper.startPage(pageNum, pageSize);
        List<ManuscriptIssue> list = baseMapper.getAll(username, phone, year, month);
        PageInfo<ManuscriptIssue> pageInfo = new PageInfo<>(list);
        return new PageBean(pageInfo.getList(), pageInfo.getTotal());
    }
}
